rtc6 2.2.1
rtc6


RTC6 Click

RTC 6 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : MikroE Team
  • Date : jan 2020.
  • Type : I2C type

Software Support

Example Description

This application enables usage of Real-TIme clock and calendar with alarm on RTC 6 Click.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Rtc6

Example Key Functions

  • rtc6_cfg_setup Config Object Initialization function.
    void rtc6_cfg_setup ( rtc6_cfg_t *cfg );
    void rtc6_cfg_setup(rtc6_cfg_t *cfg)
    Config Object Initialization function.
    Click configuration structure definition.
    Definition rtc6.h:286
  • rtc6_init Initialization function.
    err_t rtc6_init ( rtc6_t *ctx, rtc6_cfg_t *cfg );
    RTC6_RETVAL rtc6_init(rtc6_t *ctx, rtc6_cfg_t *cfg)
    Initialization function.
    Click ctx object definition.
    Definition rtc6.h:265
  • rtc6_default_cfg Click Default Configuration function.
    void rtc6_default_cfg ( rtc6_t *ctx );
    void rtc6_default_cfg(rtc6_t *ctx, int8_t time_zone, rtc6_time_t *utc_time, rtc6_time_t *alarm_time)
    Click Default Configuration function.
  • rtc6_battery_enable This function enables automatic switch to battery on VCC failure.
    void rtc6_battery_enable(rtc6_t *ctx)
    Enables automatic switch to battery.
  • rtc6_get_gmt_time This function gets current GMT time and sets it in the RTC.
    void rtc6_get_gmt_time ( rtc6_t *ctx, rtc6_time_t *gmt_time );
    void rtc6_get_gmt_time(rtc6_t *ctx, rtc6_time_t *gmt_time)
    Gets the current GMT time set in the RTC.
    Click time data object.
    Definition rtc6.h:250
  • rtc6_get_local_time his function calculates current local time.
    void rtc6_get_local_time ( rtc6_t *ctx, rtc6_time_t *local_time );
    void rtc6_get_local_time(rtc6_t *ctx, rtc6_time_t *local_time)
    Calculates the current local time.

Application Init

Initializes driver init, sets time zone, sets UTC-GMT time and alarm time

void application_init ( void )
{
log_cfg_t log_cfg;
int8_t time_zone = 2;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
rtc6_cfg_setup( &cfg );
RTC6_MAP_MIKROBUS( cfg, MIKROBUS_1 );
rtc6_init( &rtc6, &cfg );
// Set UTC time
utc_time.seconds = 40;
utc_time.minutes = 59;
utc_time.hours = 23;
utc_time.monthday = 14;
utc_time.month = 12;
utc_time.year = 18;
// Set alarm time
alarm_time.seconds = 0;
alarm_time.minutes = 0;
alarm_time.hours = 0;
alarm_time.weekdays = 0;
alarm_time.monthday = 15;
alarm_time.month = 12;
alarm_time.year = 18;
rtc6_default_cfg( &rtc6, time_zone, &utc_time, &alarm_time );
log_info( &logger, " ----- Init successfully ----- " );
}
#define RTC6_MAP_MIKROBUS(cfg, mikrobus)
Definition rtc6.h:65
void application_init(void)
Definition main.c:38

Application Task

Reads GMT time and Local time. Checks if the alarm is activated. If the alarm is active, it disable alarm and adjusts the new one within 20 seconds. Logs this data on USBUART every 900ms.

void application_task ( void )
{
// Task implementation.
rtc6_get_gmt_time( &rtc6, &utc_time );
rtc6_get_local_time( &rtc6, &local_time );
log_printf( &logger, "--- UTC time ---\r\nTime : %d %d %d\r\n", utc_time.hours, utc_time.minutes, utc_time.seconds );
log_printf( &logger, "Date : %d %d %d\r\n", utc_time.monthday, utc_time.month, utc_time.year );
log_printf( &logger, "--- Local time ---\r\nTime : %d %d %d\r\n", local_time.hours, local_time.minutes, local_time.seconds );
log_printf( &logger, "Date : %d %d %d\r\n \r\n", local_time.monthday, local_time.month, local_time.year );
if ( rtc6_is_active_alarm( &rtc6 ) != 0 )
{
log_printf( &logger, " ----- Active alarm ----- \r\n" );
}
Delay_ms ( 900 );
}
#define RTC6_ALARM_0
Definition rtc6.h:174
void rtc6_repeat_alarm(rtc6_t *ctx, uint8_t alarm, uint32_t sec)
Repeat Alarm.
uint8_t rtc6_is_active_alarm(rtc6_t *ctx)
Check if the alarm is activated.
void rtc6_disable_alarm(rtc6_t *ctx, uint8_t alarm)
Disables the alarm.
void application_task(void)
Definition main.c:88

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.